#include "stdafx.h"
#include "StarSystem.h"
#include "Player.h"

extern const int TOTALSYSTEMS=5;
extern StarSystem allSystems[TOTALSYSTEMS];

Player::Player(StarSystem& currentLocationP)
{
	currentLocation = currentLocationP;
	currentCluster = currentLocation.inCluster;
	turns=0;
}	

void Player::Teleport(string dest, int jumpType){
	//Unconditionally teleports the player by changing the player's currentLocation variable
	for (int i=0; i<TOTALSYSTEMS;i++) {
		if (dest == allSystems[i].name) {
			switch (jumpType)
			{
			case 0:
				cout<<endl<<"Hyperdrive Online..."<<endl<<"Hyperdrive Engaged."<<endl;
				break;
			case 1:
				cout<<endl<<"You approach the "<<allSystems[i].name<<" jumpgate. The autopilot takes over as you become mesmerised by the swirling patterns of its event horison."<<endl;
			case 2:
			default:
				break;
			}
			
			currentLocation=allSystems[i];
			currentCluster=currentLocation.inCluster;
			if (allSystems[i].beenVisited!=true) {
				allSystems[i].beenVisited=true;
			}
			GetSystemDescription();
			//display menu
		}
	}
}

void Player::Move(string dest) {
	//conditionally move player (system must be in current cluster and adjecent to the current one)
	for (int i=0; i<TOTALSYSTEMS; i++) {
		if (dest == allSystems[i].name && allSystems[i].inCluster == currentCluster && currentLocation.SystemInAdjList(dest)) {					//TODO: add adjecency check DONE
			Teleport(dest);
		}	else if (dest == allSystems[i].name && allSystems[i].inCluster == currentCluster) {
			cout<< "conditions not met for jump..."<<endl;
		}
	}
}

void Player::GetSystemDescription() {
	//prints the current system's name and description
	//StarSystem currSys = currentLocation;
	string name = "<" + (currentLocation).name + ">";
	string desc = (currentLocation).description;
	int asdlVectorSize=currentLocation.adjSystemsDispList.size();
	string suSy = "";
	for (int i=0; i<asdlVectorSize;i++) 
	{
		suSy += currentLocation.adjSystemsDispList[i] + " ";
	}
	cout<<endl<<  name  <<endl<<  desc  <<endl<<endl<<  suSy  <<endl<<endl;
}
